/*
 * @Author: taoyuqing
 * @Date: 2022-12-22 22:12:09
 * @Description: 游戏分类title
 */
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:spree/utils/utils.dart';

class GameGroupTitle extends StatefulWidget {
  final String titleUrl;
  final String titleName;
  final Function? onTapRight;
  GameGroupTitle(
      {Key? key,
      required this.titleUrl,
      required this.titleName,
      this.onTapRight})
      : super(key: key);

  @override
  State<GameGroupTitle> createState() => _GameGroupTitleState();
}

class _GameGroupTitleState extends State<GameGroupTitle> {
  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Container(
          width: Utils().getScreenWidth(context) - 40,
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                child: Row(
                  children: [
                    Container(
                      width: 20,
                      height: 20,
                      child: Image.asset(widget.titleUrl),
                    ),
                    Container(
                      margin: const EdgeInsets.only(left: 15),
                      child: Text(
                        widget.titleName,
                        style: const TextStyle(color: Color(0xFFB0AFEC)),
                      ),
                    )
                  ],
                ),
              ),
              GestureDetector(
                onTap: () {
                  if (widget.onTapRight != null) {
                    widget.onTapRight!();
                  }
                },
                child: Container(
                  decoration: const BoxDecoration(
                      color: Color(0xFF251D59),
                      borderRadius: BorderRadius.all(Radius.circular(8.0))),
                  padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
                  child: const Text(
                    'All Games',
                    style: TextStyle(color: Color(0xFFB0AFEC)),
                  ),
                ),
              )
            ],
          ),
        )
      ],
    );
  }
}
